home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / pointlist / ptlMesh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-12  |  1.7 KB  |  69 lines

  1. #include "ooglutil.h"
  2. #include "geom.h"
  3. #include "meshP.h"
  4. #include "pointlistP.h"
  5.  
  6.  
  7. void *mesh_PointList_get(int sel, Geom *geom, va_list args);
  8. void *mesh_PointList_fillin(int sel, Geom *geom, va_list args);
  9. void *mesh_PointList_set(int sel, Geom *geom, va_list args);
  10. void *mesh_PointList_length(int sel, Geom *geom, va_list args);
  11.  
  12. #define MAX_METHODS 4
  13.  
  14. static SpecFunc methods[] = {
  15.   "PointList_get", mesh_PointList_get,
  16.   "PointList_fillin", mesh_PointList_fillin,
  17.   "PointList_set", mesh_PointList_set,
  18.   "PointList_length", mesh_PointList_length
  19. };
  20.  
  21. static char msg[] = "ptlMesh.c";
  22.  
  23. ptlMesh_init() {
  24.   pointlist_initspec(methods, MAX_METHODS, GeomClassLookup("mesh"));
  25. }
  26.  
  27. void *mesh_PointList_get(int sel, Geom *geom, va_list args) {
  28.   HPoint3 *pt;
  29.   Mesh *m = (Mesh *)geom;
  30.   float **f;
  31.   pt = OOGLNewNE(HPoint3, m->nu * m->nv, msg);
  32.   f = va_arg(args, float **);
  33.   return GeomCall(GeomMethodSel("PointList_fillin"), geom, f, 0, pt);
  34. }
  35.  
  36. void *mesh_PointList_fillin(int sel, Geom *geom, va_list args) {
  37.   HPoint3 *pt;
  38.   float **t;
  39.   Mesh *m = (Mesh *)geom;
  40.  
  41.   t = va_arg(args, float **);
  42.   va_arg(args, int);
  43.   pt = va_arg(args, HPoint3 *);
  44.  
  45.   bcopy(m->p, pt, m->nu * m->nv * sizeof(HPoint3));
  46.   HPt3TransformN(t, pt, pt, m->nu * m->nv);
  47.  
  48.   return pt;
  49. }
  50.  
  51. void *mesh_PointList_set(int sel, Geom *geom, va_list args) {
  52.   Mesh *m = (Mesh *)geom;
  53.   HPoint3 *plist;
  54.  
  55.   /* This will make the mesh no longer a z-mesh (in general, this
  56.    * is desirable although we may regret it later */
  57.   m->flag &= ~MESH_Z;
  58.  
  59.   va_arg(args, int);
  60.   plist = va_arg(args, HPoint3 *);
  61.   bcopy(plist, m->p, m->nu * m->nv * sizeof(HPoint3));
  62.   return geom;
  63. }
  64.  
  65. void *mesh_PointList_length(int sel, Geom *geom, va_list args) {
  66.   Mesh *m = (Mesh *)geom;
  67.   return((void *)(m->nu * m->nv));
  68. }
  69.